﻿<local:MyWindow x:Class="MercuryFE.GameDetails"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:local="clr-namespace:MercuryFE"
    WindowStartupLocation="CenterOwner"
    Title="Game Detail Viewer"   >
    
    
    
    <Window.Resources>


        
        <local:FontSizeConverter x:Key="fontSizeConverter" />


        <ControlTemplate x:Key="template" TargetType="{x:Type FlowDocumentPageViewer}">
            <Border
                                      BorderThickness="{TemplateBinding Border.BorderThickness}"
                                      BorderBrush="{TemplateBinding Border.BorderBrush}"
                                      Margin="{TemplateBinding Control.Padding}"
                                      HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
                                      VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
                                      x:Uid="Border_47">
                <AdornerDecorator
                                                ClipToBounds="True"
                                                x:Uid="AdornerDecorator_1">
                    <DocumentPageView
                                                          DocumentPaginator="{x:Null}"
                                                          PageNumber="0"
                                                          KeyboardNavigation.TabIndex="1"
                                                          KeyboardNavigation.IsTabStop="False"
                                                          KeyboardNavigation.TabNavigation="Local"
                                                          x:Uid="DocumentPageView_1"
                                                          DocumentViewerBase.IsMasterPage="True" />
                </AdornerDecorator>
            </Border>

        </ControlTemplate>



        <DataTemplate x:Key="dtDetails">

            <DockPanel
                Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemsControl}}}" 
                Height="{Binding Path=ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemsControl}}}"
                 Background="Transparent">

                <FlowDocumentPageViewer  Background="Transparent" Document="{Binding}" Template="{StaticResource template}"   />
                   
            </DockPanel>

        </DataTemplate>
        
        <ItemsPanelTemplate x:Key="vDetails">
            <StackPanel  Orientation="Horizontal" IsItemsHost="True" Background="Transparent" />
        </ItemsPanelTemplate>


        <Style TargetType="{x:Type ListBoxItem}">
            <!--<Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualHeight, Converter={StaticResource fontSizeConverter}, ConverterParameter=40}" />-->
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontFamily" Value="Consolas"/>
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White" />
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
            </Style.Resources>
        </Style>

        <Style x:Key="FlowDocumentNormal" TargetType="{x:Type FlowDocument}">
            <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualHeight, Converter={StaticResource fontSizeConverter}, ConverterParameter=40}" />
            <Setter Property="ColumnWidth" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualWidth}" />
            <Setter Property="PageWidth" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualWidth}" />
            <Setter Property="IsColumnWidthFlexible" Value="True"/>
        </Style>
        
        <Style x:Key="FlowDocumentSplit" TargetType="{x:Type FlowDocument}">
            <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualHeight, Converter={StaticResource fontSizeConverter}, ConverterParameter=40}" />
            <Setter Property="ColumnWidth" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualWidth, Converter={StaticResource fontSizeConverter}, ConverterParameter=2.2}" />
            <Setter Property="PageWidth" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=ActualWidth}" />
            <Setter Property="IsColumnWidthFlexible" Value="False"/>
        </Style>




        <Style TargetType="{x:Type Image}">
            <Setter Property="Height" Value="{Binding ElementName=Viewer, Path=ActualHeight, Converter={StaticResource fontSizeConverter}, ConverterParameter=42}" />
        </Style>
        
    </Window.Resources>

    
    
    <Grid x:Name="mainGrid" Background="Black"> <!--{StaticResource backgroundGradient}">-->
        <Grid.RowDefinitions>
            <RowDefinition Height="1*" />
            <RowDefinition Height="25*" />
        </Grid.RowDefinitions>

        <Viewbox>
            <TextBlock  x:Name="tbName" Grid.Row="0" MaxHeight="40"  FontFamily="Consolas"  Foreground="White" VerticalAlignment="Center" />
        </Viewbox>


         <ListBox x:Name="Viewer" Grid.Row="1" BorderThickness="0" Background="Transparent"  
                  ItemTemplate="{StaticResource dtDetails}" 
                  ItemsPanel="{StaticResource vDetails}" 
                  ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" />


        </Grid>
</local:MyWindow>
